<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%
	request.setAttribute("path", request.getContextPath());
%>
<c:forEach items="${resources}" var="moduleItem" varStatus="vs">
<div class="accordion" id="accordion${vs.count}">
  <div class="accordion-group">
    <div class="accordion-heading">
      <h4 >
        <a class="accordion-toggle" data-toggle="collapse"data-parent="#accordion" href="#collapse${vs.count}" style="padding:0px">
        	<strong>&nbsp;<c:out value="${moduleItem.key }"/></strong>
        </a>
      </h4>
    </div>
    <div id="collapse${vs.count}" class="accordion-body collapse in">
      <div class="accordion-inner">
      		<c:forEach items="${moduleItem.value}" var="subItem" varStatus="subVS">
							<label class="checkbox inline success" style="width: 110px;color: blue;">
								<input  value="resources${subVS.count}" type="checkbox" onclick="subItemClick(this,'resources${vs.count}${subVS.count}')">
								<c:out value="${subItem.key }"/>
							</label>
							<c:forEach items="${subItem.value}" var="item" varStatus="subSubVS">
									<c:if test="${!subSubVS.first && (subSubVS.index mod 6 == 0) }">
										<br>
									</c:if>
										<c:set var="isChecked" value="false"/>
										<c:forEach items="${myResources}" var="gr" >
											<c:if test="${!isChecked && gr.id == item.id}">
												<c:set var="isChecked" value="true"/>
											</c:if>
										</c:forEach>
										<c:choose>
												<c:when test="${ isChecked}">
													<label class="checkbox inline" style="width: 110px;">
													<input  name="resources" id="resources${vs.count}${subVS.count}${subSubVS.count}" checked value="${item.id }" type="checkbox">
													<c:out value="${item.name  }"/>
													</label>
												</c:when>
												<c:otherwise>
													<label class="checkbox inline" style="width: 110px;">
													<input name="resources" value="${item.id }" id="resources${vs.count}${subVS.count}${subSubVS.count}" type="checkbox" >
													<c:out value="${item.name  }"/>
													</label>
												</c:otherwise>
										</c:choose>
										
							</c:forEach>
				 <hr>
				</c:forEach>
      </div>
    </div>
  </div>
</c:forEach>
<script type="text/javascript">
function subItemClick(obj,id){
	 $(".accordion-inner input[id^='"+id+"']").each(function(){
			$(this).prop("checked",$(obj).prop("checked"));
	}); 
}
</script>
	
		